package com.example.safehome;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

public class FireAdapter extends ArrayAdapter<FireWarningRecord> {
    private int resourceId;

    public FireAdapter(Context context, int textViewResourceId, List<FireWarningRecord>bojects) {
        super(context, textViewResourceId, bojects);
        resourceId = textViewResourceId;
    }

    @Override
        public View getView(int position, View converView, ViewGroup parent){
            //控件初始化
            FireWarningRecord record=getItem(position);
            View view= LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
            TextView id=(TextView)view.findViewById(R.id.tv_id);
            TextView fireTime=(TextView)view.findViewById(R.id.tv_fire_time);
            TextView firePlace=(TextView)view.findViewById(R.id.tv_fire_place);
            TextView isCallPolice=(TextView)view.findViewById(R.id.tv_is_call_police);
            TextView Detail=(TextView)view.findViewById(R.id.tv_detail);
            id.setText(Integer.toString(record.getId()));
            fireTime.setText(record.getFireTime().toString());
            firePlace.setText(record.getFirePlace());
            if(record.getIsCallPolice())
                isCallPolice.setText("是");
            else
                isCallPolice.setText("否");
            Detail.setText(record.getDetail());
            return view;
        }
}
